import 'package:flutter/material.dart';

class CommonTag extends StatelessWidget {
  final String title;
  final Color color;
  final Color backgroundColor;

  const CommonTag.origin({
    super.key,
    required this.title,
    this.color = Colors.black,
    this.backgroundColor = Colors.grey,
  });

  factory CommonTag({required String title}) {
    switch (title) {
      case '近地铁':
        return CommonTag.origin(
          title: title,
          color: Colors.green,
          backgroundColor: Colors.green.shade50,
        );
      case '随时看房':
        return CommonTag.origin(
          title: title,
          color: Colors.blue,
          backgroundColor: Colors.blue.shade50,
        );
      case '新上':
        return CommonTag.origin(
          title: title,
          color: Colors.green,
          backgroundColor: Colors.green.shade50,
        );
      case '集中供暖':
        return CommonTag.origin(
          title: title,
          color: Colors.grey,
          backgroundColor: Colors.grey.shade50,
        );
      default:
        return CommonTag.origin(title: title);
    }
  }

  @override
  Widget build(BuildContext context) {
    return Container(
      margin: const EdgeInsets.only(right: 4.0),
      padding:
          const EdgeInsets.only(left: 6.0, right: 6.0, top: 4.0, bottom: 4.0),
      decoration: BoxDecoration(
          color: backgroundColor, borderRadius: BorderRadius.circular(12.0)),
      child: Text(
        title,
        style: TextStyle(color: color, fontSize: 12.0),
      ),
    );
  }
}
